let nums = [1]
var rotate = function(nums, k) {
    const len = nums.length               
    let newnums = [len]
    for(let i = 0; i<k;i++){
        newnums[i] = nums[len-k+i];
    }
    nums.unshift(...newnums);
    if(k==0){
        k++
    }
    nums.splice(len,k);
    console.log(nums);
};
rotate(nums,0)
